const app=getApp();
Component({
    properties: {
      modalHidden: {
        type: Boolean,
        value: true
      }, //这里定义了modalHidden属性，属性值可以在组件使用时指定.写法为modal-hidden  
      modalMsg: {
        type: String,
        value: ' ',
      }
    },
    data: {
      // 这里是一些组件内部数据  
      text: "text",
    },
    user:null,
    methods: {
      // 这里放置自定义方法  
      cacheTimer:null,
      cacheVal:null,
      cacheContent:function(d){
        this.cacheVal=d.detail.value;
        if(this.cacheTimer) return;
        this.cacheTimer=setInterval(()=>{
          this.cacheTimer=null;
          wx.setStorageSync('cache-content', this.cacheVal)
        },1000)
      },
      //取消评论，隐藏评论弹框
      cancelComment: function(){
        this.setData({modalHidden: true});
       },
      modal_click_Hidden: function () {
        this.setData({
          modalHidden: true,
        })
      },
      // 确定  
      // Sure: function () {
      //   console.log(this.data.text)
      // }
      //发布评论
      postComment:function(){
        this.user=wx.getStorageSync('user')
        wx.request({
          url:`${app.globalData.url}/comment/interactive_Comments`,  
          method:'POST',
          data:{
            videoId:wx.getStorageSync('videoId'),
            userId:this.user.userId,
            content:this.cacheVal,
            type:2
          },
          header:{'content-type':'application/json'},
          success:ret=>{
            this.modal_click_Hidden();
            // this.data.comments=this.data.comments.unshift({content:this.cacheVal})
          }
        })
      },
    }
  })